/***************************************************************************
 *   Copyright (C) 2007 by Marcin Swiechowicz   *
 *   marcin.swiechowicz@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include "kdclabel.h"

#include <QFont>
#include <QPalette>

KDCLabel::KDCLabel( QWidget *parent ) : QLabel( parent )
{

}

KDCLabel::KDCLabel( const QString& str, QWidget *parent ) : QLabel( str, parent )
{

}

KDCLabel::~KDCLabel()
{

}

void KDCLabel::setMode( KDC::MessageType aType )
{
	QPalette palette = this->palette();
	if ( aType == KDC::Info )
		palette.setColor( QPalette::Window, QColor::fromRgb( 0, 255, 0 ) );
	else
		if ( aType == KDC::Error )
			palette.setColor( QPalette::Window, QColor::fromRgb( 255, 0, 0 ) );
	else
		palette.setColor( QPalette::Window, QColor::fromRgb( 238, 238, 52 ) );
	setPalette( palette );
	setAutoFillBackground( true );
}

void KDCLabel::setPointSize( int size )
{
	QFont font = this->font();
	font.setPointSize( size );
	setFont( font );
}

void KDCLabel::mousePressEvent( QMouseEvent * event )
{
	QLabel::mousePressEvent( event );
	emit clicked();
}

void KDCLabel::setData( QVariant data )
{
	p_data = data;
}

QVariant KDCLabel::data() const
{
	return p_data;
}

void KDCLabel::setColor( const QColor& color )
{
	QPalette p = this->palette();
	p.setColor( QPalette::Active, QPalette::WindowText, color );
	setPalette( p );
}
